#!/usr/bin/env python
# -*- indent-tabs-mode: nil; tab-width: 4; coding: utf-8 -*-
# vi: set ts=4 sts=4 sw=4 set smarttab set expandtab
#http://www.careercup.com/question?id=14945498
#Google interview question
import os, re, sys, getopt
import logging
import locale

if __name__ == '__main__':
    output = []
    buf = []
    while True:
        cur = sys.stdin.readline().rstrip('\n')
        #end exit
        if cur == '$$':
            sys.exit(0)
        #number stream ends
        if cur == '$':
            if len(buf) > 0:
                if buf[-1] == 9:
                    output.append(buf[0] + 1)
                    if len(buf) > 1:
                        output.extend([0] * (len(buf) - 1))
                else:
                    buf[-1] = buf[-1] + 1;
                    output.extend(buf)
            print output
            output = []
            buf = []
        #if there is a <9, then put all previous number into output
        elif int(cur) < 9:
            if len(buf) > 0:
                output.extend(buf)
                buf = []
            buf.append(int(cur))
        #if there is a 9, then put into buf
        elif int(cur) == 9:
            buf.append(int(cur))
        else:
            print "Ignoring char %s"%cur
    
